class BootStrapForm:

    bootstrap_class_exclude = [] # 对bootstrap样式失效的列表

    def __init__(self, *args, **kwargs):
        """
        重写ModelForm的__init__方法 ，给form添加样式
        :param args:
        :param kwargs:
        """
        super().__init__(*args, **kwargs)
        for name, field in self.fields.items():
            if name in self.bootstrap_class_exclude:
                continue
            field.widget.attrs['class'] = 'form-control'
            field.widget.attrs['placeholder'] = f'请输入{field.label}'